package com.turing.data.scripts.contract.transfer

import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO


class Duration_30200_10_transfer {

    static List< TaskElementVO.DrawResultVO > doConvert(List< TaskElementVO.DrawResultVO > resultVOs, DependParamsVO dependParams){

        for( drawResultVO in resultVOs ) {
                def childTaskSn = drawResultVO.childTaskSn
                if(null == childTaskSn || childTaskSn == ""){
                    continue
                }
            String modelValue = drawResultVO.text

            String REGEX_DURATION_YEAR = /.*\d.*年.*/

            String REGEX_DURATION_MONTH_1 = /.*\d.*个月.*/
            String REGEX_DURATION_MONTH_2 = /.*\d.*月.*/

            String REGEX_DURATION_DAY_1 = /.*\d.*日.*/
            String REGEX_DURATION_DAY_2 = /.*\d.*天.*/

            if (modelValue =~ REGEX_DURATION_YEAR) {
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int years = 0
                for(num in numbers){
                    years = num
                }
                drawResultVO.businessValue = years * 12 + "个月"
                drawResultVO.type = 1
            } else if (modelValue =~ REGEX_DURATION_MONTH_1 || modelValue =~ REGEX_DURATION_MONTH_2) {
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int months = 0
                for(num in numbers){
                    months = num
                }
                drawResultVO.businessValue = months + "个月"
                drawResultVO.type = 1
            } else if (modelValue =~ REGEX_DURATION_DAY_1 || modelValue =~ REGEX_DURATION_DAY_2) {
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int days = 0
                for(num in numbers){
                    days = num
                }
                drawResultVO.businessValue = days + "日"
                drawResultVO.type = 1
            } else {
                drawResultVO.businessValue = "无固定期限"
                drawResultVO.type = 1
            }
        }

        return resultVOs
    }

}
